
/**
 * 把数组转成树结构
 * @param {Array} data 
 * @param {*} pid 
 */
const setTree = (data, pid)=> {
  var result = []
  data.forEach(ele => {
    if(ele.pid == pid) {
      let children = setTree(data, ele.id)
      if(children.length)  ele.children = children;
      result.push(ele)
    }
   
  });
  return result;
}
module.exports = {setTree}